package com.yegs.hospital.controller;

import com.yegs.hospital.common.Msg;
import com.yegs.hospital.service.CaptchaService;
import com.yegs.hospital.vo.Captcha;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/captcha")
public class CaptchaController {

    @Autowired
    private CaptchaService captchaService;

    @GetMapping("/get")
    public Msg get(){
        return Msg.success(captchaService.get());
    };

    @PostMapping("/save")
    public Msg save(@RequestBody Captcha captcha){
        try {
            captchaService.save(captcha);
            return Msg.success();
        }catch (Exception e){
            e.printStackTrace();
            return Msg.error(e.getMessage());
        }
    };



}
